<?php

/*
 * Builds Low detailed report
 * 
 */

foreach (@ $forperiod as $team => $name) {
    echo '<li><b>' . $team . '</b>';
    echo '<table><tr><td><b>TSE Name</td>
            <td title="Closed SRs"><b>Closed</b></td>
            <td title="Tier-3 hands off activated"><b>Tier3</b></td>
            <td title="Tier-3 hands off (%)"><b>(%)</b></td>
            <td title="KCS documents linked"><b>Linked</b></td>
            <td title="KCS documents linked (%)"><b>(%)</b></td>
            <td title="Surveys"><b>Surveys</b></td>
            <td title="Technical skill with Genesys software"><b>Skill</b></td>
            <td title="Keeping you advised of the ticket status"><b>Advised</b></td>
            <td title="Professionalism"><b>Professional</b></td>
            <td title="Time to receive resolution"><b>Time</b></td>
            <td title="Effectiveness of resolution"><b>Effectivness</b></td>
            <td title="Overall satisfaction"><b>Overall</b></td>
            <td title="Top marks (%)"><b>Top marks (%)</b></td></tr>';

    foreach (@ $forperiod[$team] as $name => $value) {
        echo '<tr><td>' . $name . '</td>';
        echo '<td title="Closed SRs">' . $forperiod[$team][$name]['closed'] . '</td>';
        echo '<td title="Tier-3 hands off"';
        if ($forperiod[$team][$name]['tier3per'] >= $tier3_threshold)
            echo ' class="red"';
        echo '>' . $forperiod[$team][$name]['tier3'] . '</td>';
        echo '<td title="Tier-3 hands off (%)"';
        if ($forperiod[$team][$name]['tier3per'] >= $tier3_threshold)
            echo ' class="red"';
        echo '>' . $forperiod[$team][$name]['tier3per'] . '</td>';
        echo '<td title="KCS docs linked"';
        if ($forperiod[$team][$name]['kcsper'] < $kcs_threshold)
            echo ' class="red"';
        echo '>' . $forperiod[$team][$name]['kcs'] . '</td>';
        echo '<td title="KCS docs linked(%)"';
        if ($forperiod[$team][$name]['kcsper'] < $kcs_threshold)
            echo ' class="red"';
        echo '>' . $forperiod[$team][$name]['kcsper'] . '</td>';
        //echo '<td title="Closure RCA Activities">' . $forperiod[$team][$name]['rca'] . '</td>';
        //echo '<td title="Closure RCA Activities (%)">' . $forperiod[$team][$name]['rcaper'] . '</td>';
        //echo '<td title="Assigned to Tech Leads">' . $forperiod[$team][$name]['techlead'] . '</td>';
        //echo '<td title="Assigned to Tech Leads (%)">' . $forperiod[$team][$name]['tlaper'] . '</td>';
        echo '<td title="Surveys">' . $forperiod[$team][$name]['surveys'] . '</td>';
        echo '<td title="Skill with Genesys"';
        if ($forperiod[$team][$name]['skill'] <= $cs_threshold and $forperiod[$team][$name]['skill'] > 0)
            echo ' class="red"';
        echo '>' . $forperiod[$team][$name]['skill'] . '</td>';
        echo '<td title="Advised"';
        if ($forperiod[$team][$name]['advised'] <= $cs_threshold and $forperiod[$team][$name]['advised'] > 0)
            echo ' class="red"';
        echo '>' . $forperiod[$team][$name]['advised'] . '</td>';
        echo '<td title="Professionalism"';
        if ($forperiod[$team][$name]['prof'] <= $cs_threshold and $forperiod[$team][$name]['prof'] > 0)
            echo ' class="red"';
        echo '>' . $forperiod[$team][$name]['prof'] . '</td>';
        echo '<td title="Time to resolution"';
        if ($forperiod[$team][$name]['time'] <= $cs_threshold and $forperiod[$team][$name]['time'] > 0)
            echo ' class="red"';
        echo '>' . $forperiod[$team][$name]['time'] . '</td>';
        echo '<td title="Effectivnes"';
        if ($forperiod[$team][$name]['efect'] <= $cs_threshold and $forperiod[$team][$name]['efect'] > 0)
            echo ' class="red"';
        echo '>' . $forperiod[$team][$name]['efect'] . '</td>';
        echo '<td title="Overall"';
        if ($forperiod[$team][$name]['overall'] <= $cs_threshold and $forperiod[$team][$name]['overall'] > 0)
            echo ' class="red"';
        echo '>' . $forperiod[$team][$name]['overall'] . '</td>';
        echo '<td title="Top Marks"';
        if ($forperiod[$team][$name]['topmarks'] < $topmarks_threshold and $forperiod[$team][$name]['topmarks'] > 0)
            echo ' class="red"';
        echo '>' . $forperiod[$team][$name]['topmarks'] . '</td>';
        echo '</tr>';
    }
    echo '<tr>';
    echo '<td><b>Total</b></td>';
    echo '<td><b>' . $totalforperiod[$team]['closed'] . '</b></td>';
    echo '<td';
    if ($totalforperiod[$team]['tier3per'] >= $tier3_threshold)
        echo ' class="red"';
    echo '><b>' . $totalforperiod[$team]['tier3'] . '</b></td>';
    echo '<td';
    if ($totalforperiod[$team]['tier3per'] >= $tier3_threshold)
        echo ' class="red"';
    echo '><b>' . $totalforperiod[$team]['tier3per'] . '</b></td>';
    echo '<td';
    if ($totalforperiod[$team]['kcsper'] < $kcs_threshold)
        echo ' class="red"';
    echo '><b>' . $totalforperiod[$team]['kcs'] . '</b></td>';
    echo '<td';
    if ($totalforperiod[$team]['kcsper'] < $kcs_threshold)
        echo ' class="red"';
    echo '><b>' . $totalforperiod[$team]['kcsper'] . '</b></td>';
    //echo '<td> </td><td> </td><td> </td><td> </td>';
    echo '<td><b>' . $totalforperiod[$team]['surveys'] . '</b></td>';
    echo '<td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td>';
    echo '</tr>';

    echo '</table><br><br>';
    
    if ($_POST['_products'] == 'on') require 'buildlowproducts.php';
}
?>
